﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PocketEngine.Maths
{
    public class pVec2
    {
        public float X;
        public float Y;
        public pVec2(float x, float y)
        {
            X = x;
            Y = y;
        }
        public pVec2()
        {
            X = Y = 0;
        }
        public pVec2(pVec2 from)
        {
            X = from.X;
            Y = from.Y;
        }
        public void Normalize()
        {
            float mag = (float)Math.Sqrt( (double)X * X + Y * Y);
            if (mag < 0.0001)
            {
                mag = 1;
            }
            X = X / mag;
            Y = Y / mag;
        }
        public float Length()
        {
            return (float)Math.Sqrt((double)X*X+Y*Y);
        }
    }
}
